    function Asteroid(boardIdin, scrCallBack) {
        function GameLoader(boardId) { 
            var canvas = document.getElementById(boardId);
            var ctx = canvas.getContext("2d");
            this.ScoreCallBack = scrCallBack;
            this.boardX = 750;
            this.boardY = 700;
            this.levelUp = true;
            this.level = 0;
            this.rocks = new Array();
            this.noRocks = 0;
            this.score = 0;
            this.RenderHud = function() {
                ctx.fillStyle = "rgb(128,128,32)";
                ctx.font = "20pt Arial";
                ctx.fillText("Level: " + this.level, 50, 25);
                ctx.fillText("Lives: " + this.Ship.life, 180, 25);
                ctx.fillText("Score: " + this.score, 310, 25);
                if (this.Ship.maxNukes > 0) {
                    ctx.fillText("Nukes: " + this.Ship.maxNukes, 440, 25);
                }
                ctx.fillText("Weapons mode:", 50, 50);
                ctx.fillText(this.Ship.getWeaponsType(), 300, 50);
                ctx.fillText("Steering mode:", 50, 75);
                ctx.fillText(this.Ship.getSteeringType(), 300, 75);
                //ctx.font = "20pt Arial"; + this.Ship.fireType
                //ctx.fillText(("Score: " + this.score), 0, 30);
            }
            this.Ship = new function() {
                //starboard = right, port = left
                this.steeringType = 1;
                this.bullets = new Array();
                this.noBullets = 0;
                this.shipLength = 50;
                this.shipWidth = 30;
                this.bowDeg = 0;
                this.thrustDeg = 0;
                this.shipX = 350;
                this.shipY = 400;
                this.shipDeg = 0;
                this.thrust = 0;
                this.rotation = 0;
                this.life = 3;
                this.fireType = 0;
                this.maxNukes = 0;
                this.die = function() {
                    this.shipX = window.GameLoaderAsteroid.boardX / 2;
                    this.shipY = window.GameLoaderAsteroid.boardY / 2;
                    this.dead = true;
                    this.thrust = 0;
                    this.bowDeg = 0;
                    this.life--;
                }
                this.getWeaponsType = function() {
                    switch (this.fireType) {
                        case 0:
                            return "Canon";
                        case 1:
                            return "Mine";
                        case 2:
                            return "Laser";
                        case 3:
                            return "Nuke";
                    }
                }
                this.getSteeringType = function() {
                    switch (this.steeringType) {
                        case 0:
                            return "Zero-G";
                        case 1:
                            return "Classic";
                    }
                }
                this.toggleArms = function(intlevel) {
                    this.fireType++;
                    document.title = intlevel;
                    if (intlevel > 9) {
                        this.fireType = this.fireType > 3 ? 0 : this.fireType; //nuke (unlimited)
                    } else if (intlevel > 6) {
                        this.fireType = this.fireType > 2 ? 0 : this.fireType; //laser (unlimited)
                    } else if (intlevel > 3) {
                        this.fireType = this.fireType > 1 ? 0 : this.fireType; //mine (unlimited)
                    } else {
                        this.fireType = 0; //canon (unlimited)
                    }
                }
                this.draw = function() {
                    if ((this.shipX < 0 | this.shipX > window.GameLoaderAsteroid.boardX) | (this.shipY < 0 | this.shipY > window.GameLoaderAsteroid.boardY)) {
                        if (this.shipX < 0) {
                            this.shipX = window.GameLoaderAsteroid.boardX;
                        }
                        if (this.shipX > window.GameLoaderAsteroid.boardX) {
                            this.shipX = 0;
                        }
                        if (this.shipY < 0) {
                            this.shipY = window.GameLoaderAsteroid.boardY;
                        }
                        if (this.shipY > window.GameLoaderAsteroid.boardY) {
                            this.shipY = 0;
                        }
                    }

                    this.shipDeg += this.rotation;
                    this.thrust = this.thrust > 20 ? 20 : this.thrust;
                    this.thrust = this.thrust < 0 ? 0 : this.thrust;
                    var steerDegree = 0;
                    switch (this.steeringType) {
                        case 0:
                            this.shipX = this.shipX + Math.sin(this.thrustDeg * Math.PI / 180) * this.thrust;
                            this.shipY = this.shipY - Math.cos(this.thrustDeg * Math.PI / 180) * this.thrust;
                            break;
                        case 1:
                            this.shipX = this.shipX + Math.sin(this.shipDeg * Math.PI / 180) * this.thrust;
                            this.shipY = this.shipY - Math.cos(this.shipDeg * Math.PI / 180) * this.thrust;
                            break;
                    }
                    var bowX = Math.sin(this.shipDeg * Math.PI / 180) * (this.shipLength / 2) + (this.shipX);
                    var bowY = this.shipY - Math.cos(this.shipDeg * Math.PI / 180) * (this.shipWidth / 2);
                    var shipimage = new Image();
                    shipimage.src = 'http://12-games-of-christmas.googlecode.com/svn/trunk/assets/ship.gif';
                    ctx.translate(bowX, bowY);
                    ctx.rotate(this.shipDeg * Math.PI / 180);
                    ctx.drawImage(shipimage, (-this.shipWidth / 2), (-this.shipLength / 2), this.shipWidth, this.shipLength);
                    ctx.rotate(-this.shipDeg * Math.PI / 180);
                    ctx.translate(-bowX, -bowY);
                    document.title = "";
                    for (var i = 0; i < this.noBullets; i++) {
                        if (this.bullets[i].inAction == true) {
                            ctx.fillStyle = "rgb(200,0,0)";
                            this.bullets[i].draw();
                        }
                    }
                };
                this.fire = function() {
                    this.bullets[this.noBullets] = new function() {
                        this.type = window.GameLoaderAsteroid.Ship.fireType;
                        this.range = 10;
                        this.inAction = true;
                        this.bulletHeading = window.GameLoaderAsteroid.Ship.shipDeg;
                        this.baseX = window.GameLoaderAsteroid.Ship.shipX;
                        this.baseY = window.GameLoaderAsteroid.Ship.shipY;
                        this.boxX = window.GameLoaderAsteroid.Ship.shipX;
                        this.boxY = window.GameLoaderAsteroid.Ship.shipY;
                        this.w = 0;
                        this.h = 0;
                        this.checkColision = function(x, y, w, h) {
                            var colided = false;
                            switch (this.type) {
                                case 0:
                                case 1:
                                case 3: //boxes
                                    if (x > this.boxX & x < this.boxX + this.w) {
                                        if (y > this.boxY & y < this.boxY + this.h) {
                                            colided = true;
                                        }
                                    }
                                    if (this.boxX > x & this.boxX < x + w) {
                                        if (this.boxY > y & this.boxY < y + h) {
                                            colided = true;
                                        }
                                    }
                                    break;
                                case 2: //lasers
                                    for (var i = 0; i < this.range; i++) {
                                        var laserTestX = this.baseX + Math.sin(this.bulletHeading * Math.PI / 180) * i;
                                        var laserTestY = this.baseY - Math.cos(this.bulletHeading * Math.PI / 180) * i;
                                        if (x < laserTestX & (x + w) > laserTestX) {
                                            if (y < laserTestY & (y + h) > laserTestY) {
                                                colided = true;
                                            }
                                        }
                                    }
                                    break;
                            }
                            if (colided & this.type != 3) {
                                this.inAction = false;
                            }
                            return colided;
                        }
                        this.draw = function() {
                            switch (this.type) {
                                case 0: //canon
                                    this.w = 5;
                                    this.h = 5;
                                    this.boxX = this.baseX + Math.sin(this.bulletHeading * Math.PI / 180) * this.range;
                                    this.boxY = this.baseY - Math.cos(this.bulletHeading * Math.PI / 180) * this.range;
                                    ctx.fillRect(this.boxX, this.boxY, this.w, this.h);
                                    break;
                                case 1: //mine
                                    this.w = 10;
                                    this.h = 10;
                                    this.boxX = this.baseX;
                                    this.boxY = this.baseY;
                                    ctx.fillRect(this.boxX, this.boxY, this.w, this.h);
                                    break;
                                case 2: //laser
                                    ctx.beginPath();
                                    this.boxX = this.baseX + Math.sin(this.bulletHeading * Math.PI / 180) * this.range;
                                    this.boxY = this.baseY - Math.cos(this.bulletHeading * Math.PI / 180) * this.range;
                                    ctx.lineWidth = 2;
                                    ctx.moveTo(this.baseX, this.baseY); // give the (x,y) coordinates
                                    ctx.lineTo(this.boxX, this.boxY);
                                    ctx.lineTo(this.baseX, this.baseY);
                                    ctx.strokeStyle = "#f00";
                                    ctx.stroke();
                                    ctx.closePath();
                                    break;
                                case 3: //nuke
                                    this.w = window.GameLoaderAsteroid.boardX;
                                    this.h = window.GameLoaderAsteroid.boardY;
                                    this.boxX = 0;
                                    this.boxY = 0;
                                    ctx.fillStyle = "rgba(200,0,0," + (this.range / 300) + ")";
                                    ctx.fillRect(this.boxX, this.boxY, this.w, this.h);
                                    this.range += 40;
                                    break;
                            }
                            this.range += 10;
                            if (this.range > 300) {
                                this.inAction = false;
                            }
                        }
                    }
                    this.noBullets++;
                };
            };
            this.tick = function() {
                window.GameLoaderAsteroid.tickCounter++;
                if (window.GameLoaderAsteroid.Ship.dead == true) {
                    if (window.GameLoaderAsteroid.Ship.life == 0) {
                        ctx.fillStyle = "rgb(128,128,32)";
                        ctx.font = "40pt Arial";
                        ctx.fillText("Game Over", this.boardX / 2, this.boardY / 2);
                        ctx.font = "20pt Arial";
                        ctx.fillText(("Score - " + this.score), this.boardX / 2, this.boardY / 2 + 30);
                        return;
                    }
                    ctx.clearRect(0, 0, this.boardX, this.boardY);
                    window.GameLoaderAsteroid.Ship.dead = false;
                    ctx.fillStyle = "rgb(128,128,32)";
                    ctx.font = "40pt Arial";
                    ctx.fillText("Lost a life", this.boardX / 2, this.boardY / 2);
                    ctx.fillText("Get Ready", this.boardX / 2, this.boardY / 2 + 50);
                    setTimeout("window.GameLoaderAsteroid.tick()", 1000);
                    return;
                }
                if (this.levelUp) {
                    this.noBullets = 0;
                    if(this.level%10 ==0){
                        window.GameLoaderAsteroid.Ship.life++;
                        window.GameLoaderAsteroid.Ship.maxNukes++;
                    }
                    window.GameLoaderAsteroid.Ship.maxNukes = this.level - 8;
                    this.level++;
                    this.levelUp = false;
                    this.noRocks = this.level * 1;
                    for (var i = 0; i < this.noRocks; i++) {
                        this.rocks[i] = new function() {
                            this.rockHeading = Math.floor(Math.random() * 361);
                            this.rockDistance = Math.floor(Math.random() * 200) + 50;
                            this.baseX = Math.floor(Math.random() * window.GameLoaderAsteroid.boardX);
                            this.baseY = Math.floor(Math.random() * window.GameLoaderAsteroid.boardY);
                            this.rockX = this.baseX + Math.sin(this.rockHeading * Math.PI / 180) * this.rockDistance;
                            this.rockY = this.baseY - Math.cos(this.rockHeading * Math.PI / 180) * this.rockDistance;
                            this.width = 20+(window.GameLoaderAsteroid.level * 5);
                            this.height = 20+(window.GameLoaderAsteroid.level * 5);
                            this.destroyed = false;
                            this.draw = function() {
                                this.rockX = this.baseX + Math.sin(this.rockHeading * Math.PI / 180) * this.rockDistance;
                                this.rockY = this.baseY - Math.cos(this.rockHeading * Math.PI / 180) * this.rockDistance;
                                this.rockHeading += 5;
                                var rockimage = new Image();
                                rockimage.src = 'http://12-games-of-christmas.googlecode.com/svn/trunk/assets/asteroid2.gif';
                                ctx.drawImage(rockimage, this.rockX, this.rockY, this.width, this.height);
                                //ctx.fillRect(this.rockX, this.rockY, 30, 30);
                            }
                        }
                    }
                    ctx.fillStyle = "rgb(128,32,32)";
                    ctx.font = "20pt Arial";
                    ctx.fillText("Level: " + window.GameLoaderAsteroid.level, window.GameLoaderAsteroid.boardX / 2, window.GameLoaderAsteroid.boardY / 2);
                    ctx.fillText("Get Ready", window.GameLoaderAsteroid.boardX / 2, window.GameLoaderAsteroid.boardY / 2 + 50);
                    if (this.level == 4) {
                        ctx.fillText("Upgrade weapons: mine", window.GameLoaderAsteroid.boardX / 2, window.GameLoaderAsteroid.boardY / 2 + 100);
                    } else if (this.level == 1) {
                        ctx.fillText("Upgrade weapons: canon", window.GameLoaderAsteroid.boardX / 2, window.GameLoaderAsteroid.boardY / 2 + 100);
                    }
                    var bonus = ((30)*this.level)-window.GameLoaderAsteroid.tickCounter;
                    if (bonus > 0){
                        window.GameLoaderAsteroid.score +=bonus;
                        ctx.fillText("Time Bonus: "+bonus, window.GameLoaderAsteroid.boardX / 2, window.GameLoaderAsteroid.boardY / 2 + 150);
                    }
                    window.GameLoaderAsteroid.tickCounter = 0;
                    setTimeout("window.GameLoaderAsteroid.tick()", 2000);
                    return;
                }
                ctx.clearRect(0, 0, this.boardX, this.boardY);

                window.GameLoaderAsteroid.RenderHud();
                for (var i = 0; i < this.noRocks; i++) {
                    var rock = this.rocks[i];
                    var ship = window.GameLoaderAsteroid.Ship;
                    if (rock.rockX < ship.shipX & (rock.rockX + rock.width) > ship.shipX) {
                        if (rock.rockY < ship.shipY & (rock.rockY + rock.height) > ship.shipY) {
                            if (!rock.destroyed) {
                                rock.destroyed = true;
                                ship.die();
                                setTimeout("window.GameLoaderAsteroid.tick()", 40);
                                return;
                            }
                        }
                    }
                    if (!this.rocks[i].destroyed) {
                        for (var j = 0; j < window.GameLoaderAsteroid.Ship.noBullets; j++) {
                            if (window.GameLoaderAsteroid.Ship.bullets[j].inAction) {
                                var blt = window.GameLoaderAsteroid.Ship.bullets[j];
                                if (blt.checkColision(rock.rockX, rock.rockY, rock.width, rock.height)) {
                                    rock.destroyed = true;
                                    this.score++;
                                }
                            }
                        }
                    }
                }
                var noRocksLeft = 0;
                for (var i = 0; i < this.noRocks; i++) {
                    if (!this.rocks[i].destroyed) {
                        ctx.fillStyle = "rgb(64,64,64)";
                        this.rocks[i].draw();
                        noRocksLeft++;
                    }
                }
                this.levelUp = (noRocksLeft == 0);
                this.Ship.draw();
                if (this.ScoreCallBack != undefined) {
                    this.ScoreCallBack(this.level, this.score, window.GameLoaderAsteroid.Ship.life);
                }
                setTimeout("window.GameLoaderAsteroid.tick()", 100);
            };
            canvas.onclick = function () {
                canvas.onclick = function () { };
                this.style.backgroundImage = "url(http://12-games-of-christmas.googlecode.com/svn/trunk/assets/space.jpg)";
                document.onkeyup = function (e) {
                    var charCode = this.KeyID = (window.event) ? event.keyCode : e.keyCode;
                    switch (charCode) {
                        case 32:
                            if (!(window.GameLoaderAsteroid.Ship.maxNukes == 0 && window.GameLoaderAsteroid.Ship.fireType == 3)) {
                                window.GameLoaderAsteroid.Ship.fire();
                                if (window.GameLoaderAsteroid.Ship.fireType == 3) {
                                    window.GameLoaderAsteroid.Ship.maxNukes--;
                                }
                            }
                            break;
                        case 81:
                            window.GameLoaderAsteroid.Ship.toggleArms(window.GameLoaderAsteroid.level);
                            if (window.GameLoaderAsteroid.Ship.maxNukes == 0) {
                                if (window.GameLoaderAsteroid.Ship.fireType == 3) {
                                    window.GameLoaderAsteroid.Ship.fireType = 0;
                                }
                            }
                            break;
                        case 39:
                            window.GameLoaderAsteroid.Ship.rotation = 0;
                            break;
                        case 37:
                            window.GameLoaderAsteroid.Ship.rotation = 0;
                            break;
                        case 67:
                            window.GameLoaderAsteroid.Ship.steeringType = window.GameLoaderAsteroid.Ship.steeringType == 0 ? 1 : 0;
                            break;
                    }
                    if (charCode == 81 || charCode == 39 || charCode == 37 || charCode == 67 || charCode == 32) {
                        return false;
                    }
                };
                document.onkeydown = function (e) {
                    var charCode = this.KeyID = (window.event) ? event.keyCode : e.keyCode;
                    switch (charCode) {
                        case 39:
                            window.GameLoaderAsteroid.Ship.rotation = 10;
                            break;
                        case 37:
                            window.GameLoaderAsteroid.Ship.rotation = -10;
                            break;
                        case 38:
                            if (window.GameLoaderAsteroid.Ship.thrustDeg != window.GameLoaderAsteroid.Ship.shipDeg) {
                                window.GameLoaderAsteroid.Ship.thrust -= 5;
                            }
                            if (window.GameLoaderAsteroid.Ship.thrust < 1) {
                                window.GameLoaderAsteroid.Ship.thrustDeg = window.GameLoaderAsteroid.Ship.shipDeg;
                            }
                            window.GameLoaderAsteroid.Ship.thrust += 3;

                            break;
                        case 40:
                            window.GameLoaderAsteroid.Ship.thrust = 0;
                            break;
                    }
                    if (charCode == 37 || charCode == 38 || charCode == 39 || charCode == 40) {
                        return false;
                    }
                };
                window.GameLoaderAsteroid.tick();
            }
        }
        window.GameLoaderAsteroid = new GameLoader(boardIdin, scrCallBack);
    }